Skip to main content

Future value

The point of this example is to show you how to translate a math formula to python code. You don't need to memorize financial math in this class.

See This formula and other formulas at wikihow.life for more info

future value

Video Demonstration on Panopto

future_value.py

# Get the desired future value.
future_value = float(input('Enter the desired future value: '))

# Get the annual interest rate.
rate = float(input('Enter the annual interest rate: '))

# Get the number of years that the money will appreciate.
years = int(input('Enter the number of years the money will grow: '))

# Calculate the amount needed to deposit.
present_value = future_value / (1.0 + rate)**years

# Display the amount needed to deposit.
print('You will need to deposit this amount:', present_value)